/* $Header: zone_tbls.c,v 2.2 01/10/02 10:29:27 przybyls Exp $ */

/* zone_tbls.c - workfile get/set for oven/zone setpoints */
/* John DeGood; September 1992 */
/* Copyright (c) 1992, Hewlett-Packard Co. */

#include <typedefs.h>
#include <pcb_defs.h>
#include <error.h>
#include <p_wkfile.h>
#include <wkfile.h>
#include <ramps.h>
#include <zone_config.h>
#include <zone_status.h>
#include <p_status.h>
#include <status.h>
#include <zone_ui.h>
#include <method.h>
#include <stddef.h>
#include <meth_config.h>
#include <exception.h>
#include <err_handler.h>
#include <p_ui.h>
#include <clock_ui.h>

#define METH_RATE METH_INT2
#define METH_TEMP METH_INT0
#define METH_TIME METH_INT2
#define METH_ZONE_ERR METH_INT0

/********************* wrapper function prototypes *********************/

static INT32 mGetAuxType(void *aux, U_INT8 ramp_number);
static INT32 mGetOvenMax(void *zone, U_INT8 ramp_number);
static INT32 mGetOvenEquibTime(void *zone, U_INT8 ramp_number);
static INT32 mGetCryoOnOff(void *zone, U_INT8 ramp_number);
static INT32 mGetCryoBlastOnOff(void *zone, U_INT8 ramp_number);
static INT32 mGetCryoAmbientTemp(void *zone, U_INT8 ramp_number);
static INT32 mGetCryoTimeout(void *zone, U_INT8 ramp_number);
static INT32 mGetCryoTimeoutOnOff(void *zone, U_INT8 ramp_number);
static INT32 mGetCryoShutdownOnOff(void *zone, U_INT8 ramp_number);
static INT32 mGetTempSetpt(void *zone, U_INT8 ramp_number);
static INT32 mGetOvenTrackModeOnOff(void *zone, U_INT8 ramp_number);
static INT32 mGetInitTempSetpt(void *zone, U_INT8 ramp_number);
static INT32 mGetInitTimeSetpt(void *zone, U_INT8 ramp_number);
static INT32 mGetRateSetpt(void *zone, U_INT8 ramp_number);
static INT32 mGetFinalTempSetpt(void *zone, U_INT8 ramp_number);
static INT32 mGetFinalTimeSetpt(void *zone, U_INT8 ramp_number);
static INT32 mGetTempOnOff(void *zone, U_INT8 ramp_number);
static INT32 mGetOvenType(void *zone, U_INT8 num);
static INT32 mGetOvenCalib(void *zone, U_INT8 num);
static INT32 mGetOvenCalibDate(void *zone, U_INT8 num);

static INT32 mGetTempZonePresence(void *zone, U_INT8 num);
static INT32 mGetZonePresence(void *zone, U_INT8 num);
static INT32 mGetCryoType(void *zone, U_INT8 num);
static INT32 mGetZoneCryoType(void *zone, U_INT8 num);
static INT32 mGetOvenMax(void *zone, U_INT8 num);
static INT32 mGetZoneMinSetpt(void *zone, U_INT8 ramp_number);
static INT32 mGetZoneMaxSetpt(void *zone, U_INT8 ramp_number);
static INT32 mGetZoneMaxRate(void *zone, U_INT8 ramp_number);

static UI_ERR mSetAuxType(void *status, INT32 setpt, U_INT8 ramp_number);
static UI_ERR mSetOvenMax(void *zone, INT32 setpt, U_INT8 ramp_number);
static UI_ERR mSetOvenEquibTime(void *zone, INT32 setpt, U_INT8 ramp_number);
static UI_ERR mSetCryoType(void *zone, INT32 setpt, U_INT8 ramp_number);
static UI_ERR mSetCryoOnOff(void *zone, INT32 setpt, U_INT8 ramp_number);
static UI_ERR mSetCryoBlastOnOff(void *zone, INT32 setpt, U_INT8 ramp_number);
static UI_ERR mSetCryoAmbientTemp(void *zone, INT32 setpt, U_INT8 ramp_number);
static UI_ERR mSetCryoTimeout(void *zone, INT32 setpt, U_INT8 ramp_number);
static UI_ERR mSetCryoTimeoutOnOff(void *zone, INT32 setpt, U_INT8 ramp_number);
static UI_ERR mSetCryoShutdownOnOff(void *zone, INT32 setpt, U_INT8 ramp_number);
static UI_ERR mSetTempSetpt(void *zone, INT32 setpt, U_INT8 ramp_number);
static UI_ERR mSetOvenTrackModeOnOff(void *zone, INT32 setpt, U_INT8 ramp_number);
static UI_ERR mSetInitTempSetpt(void *zone, INT32 setpt, U_INT8 ramp_number);
static UI_ERR mSetInitTimeSetpt(void *zone, INT32 setpt, U_INT8 ramp_number);
static UI_ERR mSetRateSetpt(void *zone, INT32 setpt, U_INT8 ramp_number);
static UI_ERR mSetFinalTempSetpt(void *zone, INT32 setpt, U_INT8 ramp_number);
static UI_ERR mSetFinalTimeSetpt(void *zone, INT32 setpt, U_INT8 ramp_number);
static UI_ERR mSetTempOnOff(void *zone, INT32 setpt, U_INT8 ramp_number);
static UI_ERR mSetOvenType(void *parm, INT32 setpt, U_INT8 num);
static UI_ERR mSetOvenMeasuredTemp(void *parm, INT32 setpt, U_INT8 num);

static UI_ERR mLetAuxType(void *zone, INT32 setpt, U_INT8 num);
static UI_ERR mLetOvenType(void *zone, INT32 setpt, U_INT8 num);
static UI_ERR mLetZonePresence(void *zone, INT32 setpt, U_INT8 num);
static UI_ERR mLetCryoType(void *zone, INT32 setpt, U_INT8 num);
static UI_ERR mLetOvenMax(void *zone, INT32 setpt, U_INT8 num);
static UI_ERR mLetZoneMinSetpt (void *status, INT32 setpt, U_INT8 num);
static UI_ERR mLetZoneMaxSetpt (void *status, INT32 setpt, U_INT8 num);
static UI_ERR mLetZoneMaxRate (void *status, INT32 setpt, U_INT8 num);

static UI_ERR DummyFunction(void *which);
static INT32  DummyGet(void *parm, U_INT8 num);
static UI_ERR DummySet(void *parm, INT32 setpt, U_INT8 num);

static UI_ERR AuxPreFunc(void *which);
static UI_ERR InletPreFunc(void *which);
static UI_ERR DetPreFunc(void *which);
static UI_ERR CryoPreFunc(void *which);

/********************* command table entries *********************/

typedef struct
{
        pZONE_TABLE const pzone;
        ZONE_TYPE const zone_type;
        U_INT16 const aux_index;
} MULTI_PTRS;

static const MULTI_PTRS mpOVXX =
{
    pOVEN_TEMP,
        OVEN_ZONE,
        0  /* unused */
};

static const MULTI_PTRS mpA1XX =
{
    pAUX_1_TEMP,
        AUXA_ZONE,
        1  /* for GetAuxType() */
};

static const MULTI_PTRS mpA2XX =
{
    pAUX_2_TEMP,
        AUXB_ZONE,
        2  /* for GetAuxType() */
};

static const MULTI_PTRS mpDFXX =
{
    pFRONT_DET_TEMP,
        DETA_ZONE,
        0  /* unused */
};

static const MULTI_PTRS mpDBXX =
{
    pBACK_DET_TEMP,
        DETB_ZONE,
        0  /* unused */
};

static const MULTI_PTRS mpIFXX =
{
    pFRONT_INLET_TEMP,
        INJA_ZONE,
        0  /* unused */
};

static const MULTI_PTRS mpIBXX =
{
    pBACK_INLET_TEMP,
        INJB_ZONE,
        0  /* unused */
};

#define pzone_status ((MULTI_PTRS * const)status)->pzone
#define zone_type_status ((MULTI_PTRS * const)status)->zone_type
#define aux_index_status (int)((MULTI_PTRS * const)status)->aux_index

static const METHCMD_ENTRY mmOVTP[] =
{
        {mGetOvenType, mSetOvenType, 0, METH_INT0}
};

static const METHCMD_ENTRY mmOVCL[] =
{
        {DummyGet, mSetOvenMeasuredTemp, 0, METH_INT2}
};

static const METHCMD_ENTRY mmOVLS[] =
{
        {mGetOvenCalib,     DummySet, 0, METH_INT2},
        {mGetOvenCalibDate, DummySet, 0, METH_INT0}
};

static const METHCMD_ENTRY mmOVCR[] =
{
        {mGetCryoOnOff, mSetCryoOnOff, 0, METH_ON_OFF},
        {mGetCryoBlastOnOff, mSetCryoBlastOnOff, 0, METH_ON_OFF},
        {mGetCryoAmbientTemp, mSetCryoAmbientTemp, 0, METH_TEMP},
        {mGetCryoTimeout, mSetCryoTimeout, 0, METH_TIME},
        {mGetCryoTimeoutOnOff, mSetCryoTimeoutOnOff, 0, METH_ON_OFF},
        {mGetCryoShutdownOnOff, mSetCryoShutdownOnOff, 0, METH_ON_OFF}
};

static const METHCMD_ENTRY mmXXCR[] =
{
   {mGetZoneCryoType,      mSetCryoType,          0, METH_INT0},
   {mGetCryoOnOff,         mSetCryoOnOff,         0, METH_ON_OFF},
   {mGetCryoBlastOnOff,    mSetCryoBlastOnOff,    0, METH_ON_OFF}, /*quick cryo cool*/
   {mGetCryoAmbientTemp,   mSetCryoAmbientTemp,   0, METH_TEMP},
   {mGetCryoTimeout,       mSetCryoTimeout,       0, METH_TIME},
   {mGetCryoTimeoutOnOff,  mSetCryoTimeoutOnOff,  0, METH_ON_OFF},
   {mGetCryoShutdownOnOff, mSetCryoShutdownOnOff, 0, METH_ON_OFF}
};

static const METHCMD_ENTRY mmOVSP[] =
{
        {mGetOvenEquibTime, mSetOvenEquibTime, 0, METH_TIME}
};

static const METHCMD_ENTRY mmOVCF[] =
{
        {mGetOvenMax, mSetOvenMax, 0, METH_TEMP}
};

static const METHCMD_ENTRY mmOVCW[] =
{
        {mGetOvenType,          mLetOvenType,           0,      METH_INT0},
        {mGetTempZonePresence,  mLetZonePresence,       0,      METH_INT0},
        {mGetCryoType,          mLetCryoType,           0,      METH_INT0},
        {mGetOvenMax,           mLetOvenMax,            0,      METH_INT0}
};

static const METHCMD_ENTRY mmAXCW[] =
{
        {mGetAuxType,           mLetAuxType,            0,      METH_INT0},
        {mGetZonePresence,      mLetZonePresence,       0,      METH_INT0}
};

static const METHCMD_ENTRY mmAXTP[] =
{
        {mGetAuxType, mSetAuxType, 0, METH_INT0}
};

static const METHCMD_ENTRY mmXXZW[] =
{
        {mGetZoneMinSetpt,      mLetZoneMinSetpt,       0,      METH_TEMP},
        {mGetZoneMaxSetpt,      mLetZoneMaxSetpt,       0,      METH_TEMP},
        {mGetZoneMaxRate,       mLetZoneMaxRate,        0,      METH_RATE}
};

static const METHCMD_ENTRY mmXXTI[] =
{
        {mGetTempSetpt, mSetTempSetpt, 0, METH_TEMP}
};

static const METHCMD_ENTRY mmXXTR[] =
{
        {mGetOvenTrackModeOnOff, mSetOvenTrackModeOnOff, 0, METH_ON_OFF},

        {mGetInitTempSetpt, mSetInitTempSetpt, 0, METH_TEMP},
        {mGetInitTimeSetpt, mSetInitTimeSetpt, 0, METH_TIME},

        {mGetRateSetpt, mSetRateSetpt, 1, METH_RATE},
        {mGetFinalTempSetpt, mSetFinalTempSetpt, 1, METH_TEMP},
        {mGetFinalTimeSetpt, mSetFinalTimeSetpt, 1, METH_TIME},

        {mGetRateSetpt, mSetRateSetpt, 2, METH_RATE},
        {mGetFinalTempSetpt, mSetFinalTempSetpt, 2, METH_TEMP},
        {mGetFinalTimeSetpt, mSetFinalTimeSetpt, 2, METH_TIME},

        {mGetRateSetpt, mSetRateSetpt, 3, METH_RATE},
        {mGetFinalTempSetpt, mSetFinalTempSetpt, 3, METH_TEMP},
        {mGetFinalTimeSetpt, mSetFinalTimeSetpt, 3, METH_TIME},

        {mGetRateSetpt, mSetRateSetpt, 4, METH_RATE},
        {mGetFinalTempSetpt, mSetFinalTempSetpt, 4, METH_TEMP},
        {mGetFinalTimeSetpt, mSetFinalTimeSetpt, 4, METH_TIME},

        {mGetRateSetpt, mSetRateSetpt, 5, METH_RATE},
        {mGetFinalTempSetpt, mSetFinalTempSetpt, 5, METH_TEMP},
        {mGetFinalTimeSetpt, mSetFinalTimeSetpt, 5, METH_TIME},

        {mGetRateSetpt, mSetRateSetpt, 6, METH_RATE},
        {mGetFinalTempSetpt, mSetFinalTempSetpt, 6, METH_TEMP},
        {mGetFinalTimeSetpt, mSetFinalTimeSetpt, 6, METH_TIME},

        {mGetRateSetpt, mSetRateSetpt, 7, METH_RATE},
        {mGetFinalTempSetpt, mSetFinalTempSetpt, 7, METH_TEMP},
        {mGetFinalTimeSetpt, mSetFinalTimeSetpt, 7, METH_TIME},

        {mGetRateSetpt, mSetRateSetpt, 8, METH_RATE},
        {mGetFinalTempSetpt, mSetFinalTempSetpt, 8, METH_TEMP},
        {mGetFinalTimeSetpt, mSetFinalTimeSetpt, 8, METH_TIME},

        {mGetRateSetpt, mSetRateSetpt, 9, METH_RATE},
        {mGetFinalTempSetpt, mSetFinalTempSetpt, 9, METH_TEMP},
        {mGetFinalTimeSetpt, mSetFinalTimeSetpt, 9, METH_TIME},

        {mGetRateSetpt, mSetRateSetpt, 10, METH_RATE},
        {mGetFinalTempSetpt, mSetFinalTempSetpt, 10, METH_TEMP},
        {mGetFinalTimeSetpt, mSetFinalTimeSetpt, 10, METH_TIME}
};

static const METHCMD_ENTRY mmXXTZ[] =
{
        {mGetTempOnOff, mSetTempOnOff, 0, METH_ON_OFF}
};

/********************* command tables *********************/

const METHCMD mOVTP =
{
        MAXINDEX(mmOVTP, METHCMD_ENTRY),
        &mmOVTP[0],
        NULL,
        DummyFunction,
        DummyFunction
};

const METHCMD mOVCL =
{
        MAXINDEX(mmOVCL, METHCMD_ENTRY),
        &mmOVCL[0],
        NULL,
        DummyFunction,
        DummyFunction
};

const METHCMD mOVLS =
{
        MAXINDEX(mmOVLS, METHCMD_ENTRY),
        &mmOVLS[0],
        NULL,
        DummyFunction,
        DummyFunction
};

const METHCMD mOVCR =
{
        MAXINDEX(mmOVCR, METHCMD_ENTRY),
        &mmOVCR[0],
        pOVEN_TEMP,
        CryoPreFunc,
        DummyFunction
};

const METHCMD mIFCR =
{
        MAXINDEX(mmXXCR, METHCMD_ENTRY),
        &mmXXCR[0],
        pFRONT_INLET_TEMP,
        CryoPreFunc,
        DummyFunction
};

const METHCMD mIBCR =
{
        MAXINDEX(mmXXCR, METHCMD_ENTRY),
        &mmXXCR[0],
        pBACK_INLET_TEMP,
        CryoPreFunc,
        DummyFunction
};

const METHCMD mA1CR =
{
        MAXINDEX(mmXXCR, METHCMD_ENTRY),
        &mmXXCR[0],
        pAUX_1_TEMP,
        CryoPreFunc,
        DummyFunction
};

const METHCMD mA2CR =
{
        MAXINDEX(mmXXCR, METHCMD_ENTRY),
        &mmXXCR[0],
        pAUX_2_TEMP,
        CryoPreFunc,
        DummyFunction
};

const METHCMD mOVSP =
{
        MAXINDEX(mmOVSP, METHCMD_ENTRY),
        &mmOVSP[0],
        pOVEN_TEMP,
        DummyFunction,
        DummyFunction
};

const METHCMD mOVCF =
{
        MAXINDEX(mmOVCF, METHCMD_ENTRY),
        &mmOVCF[0],
        pOVEN_TEMP,
        DummyFunction,
        DummyFunction
};

const METHCMD mOVCW =
{
        MAXINDEX(mmOVCW, METHCMD_ENTRY),
        &mmOVCW[0],
        (MULTI_PTRS * const) &mpOVXX,
        DummyFunction,
        DummyFunction
};

const METHCMD mA1CW =
{
        MAXINDEX(mmAXCW, METHCMD_ENTRY),
        &mmAXCW[0],
        (MULTI_PTRS * const) &mpA1XX,
        DummyFunction,
        DummyFunction
};

const METHCMD mA2CW =
{
        MAXINDEX(mmAXCW, METHCMD_ENTRY),
        &mmAXCW[0],
        (MULTI_PTRS * const) &mpA2XX,
        DummyFunction,
        DummyFunction
};

const METHCMD mA1TP =
{
        MAXINDEX(mmAXTP, METHCMD_ENTRY),
        &mmAXTP[0],
        (MULTI_PTRS * const) &mpA1XX,
        DummyFunction,
        DummyFunction
};

const METHCMD mA2TP =
{
        MAXINDEX(mmAXTP, METHCMD_ENTRY),
        &mmAXTP[0],
        (MULTI_PTRS * const) &mpA2XX,
        DummyFunction,
        DummyFunction
};

const METHCMD mDFZW =
{
        MAXINDEX(mmXXZW, METHCMD_ENTRY),
        &mmXXZW[0],
        (MULTI_PTRS * const) &mpDFXX,
        DummyFunction,
        DummyFunction
};

const METHCMD mDBZW =
{
        MAXINDEX(mmXXZW, METHCMD_ENTRY),
        &mmXXZW[0],
        (MULTI_PTRS * const) &mpDBXX,
        DummyFunction,
        DummyFunction
};

const METHCMD mIFZW =
{
        MAXINDEX(mmXXZW, METHCMD_ENTRY),
        &mmXXZW[0],
        (MULTI_PTRS * const) &mpIFXX,
        DummyFunction,
        DummyFunction
};

const METHCMD mIBZW =
{
        MAXINDEX(mmXXZW, METHCMD_ENTRY),
        &mmXXZW[0],
        (MULTI_PTRS * const) &mpIBXX,
        DummyFunction,
        DummyFunction
};

const METHCMD mOVZW =
{
        MAXINDEX(mmXXZW, METHCMD_ENTRY),
        &mmXXZW[0],
        (MULTI_PTRS * const) &mpOVXX,
        DummyFunction,
        DummyFunction
};

const METHCMD mA1ZW =
{
        MAXINDEX(mmXXZW, METHCMD_ENTRY),
        &mmXXZW[0],
        (MULTI_PTRS * const) &mpA1XX,
        DummyFunction,
        DummyFunction
};

const METHCMD mA2ZW =
{
        MAXINDEX(mmXXZW, METHCMD_ENTRY),
        &mmXXZW[0],
        (MULTI_PTRS * const) &mpA2XX,
        DummyFunction,
        DummyFunction
};

const METHCMD mOVTI =
{
        MAXINDEX(mmXXTI, METHCMD_ENTRY),
        &mmXXTI[0],
        pOVEN_TEMP,
        DummyFunction,
        DummyFunction
};

const METHCMD mIFTI =
{
        MAXINDEX(mmXXTI, METHCMD_ENTRY),
        &mmXXTI[0],
        pFRONT_INLET_TEMP,
        DummyFunction,
        DummyFunction
};

const METHCMD mIBTI =
{
        MAXINDEX(mmXXTI, METHCMD_ENTRY),
        &mmXXTI[0],
        pBACK_INLET_TEMP,
        DummyFunction,
        DummyFunction
};

const METHCMD mA1TI =
{
        MAXINDEX(mmXXTI, METHCMD_ENTRY),
        &mmXXTI[0],
        pAUX_1_TEMP,
        DummyFunction,
        DummyFunction
};

const METHCMD mA2TI =
{
        MAXINDEX(mmXXTI, METHCMD_ENTRY),
        &mmXXTI[0],
        pAUX_2_TEMP,
        DummyFunction,
        DummyFunction
};

const METHCMD mDFTI =
{
        MAXINDEX(mmXXTI, METHCMD_ENTRY),
        &mmXXTI[0],
        pFRONT_DET_TEMP,
        DummyFunction,
        DummyFunction
};

const METHCMD mDBTI =
{
        MAXINDEX(mmXXTI, METHCMD_ENTRY),
        &mmXXTI[0],
        pBACK_DET_TEMP,
        DummyFunction,
        DummyFunction
};

const METHCMD mOVTR =
{
        2 + (OVEN_RAMP_LEVELS * 3) - 1,
        &mmXXTR[1],     /* XXTR[0] is only used by IFTR and IBTR */
        pOVEN_TEMP,
        DummyFunction,
        DummyFunction
};

const METHCMD mIFTR =
{
        3 + (RAMP_LEVELS * 3) - 1,
        &mmXXTR[0],
        pFRONT_INLET_TEMP,
        InletPreFunc,
        DummyFunction
};

const METHCMD mIBTR =
{
        3 + (RAMP_LEVELS * 3) - 1,
        &mmXXTR[0],
        pBACK_INLET_TEMP,
        InletPreFunc,
        DummyFunction
};

const METHCMD mA1TR =
{
        2 + (RAMP_LEVELS * 3) - 1,
        &mmXXTR[1],     /* XXTR[0] is only used by IFTR and IBTR */
        pAUX_1_TEMP,
        AuxPreFunc,
        DummyFunction
};

const METHCMD mA2TR =
{
        2 + (RAMP_LEVELS * 3) - 1,
        &mmXXTR[1],     /* XXTR[0] is only used by IFTR and IBTR */
        pAUX_2_TEMP,
        AuxPreFunc,
        DummyFunction
};

const METHCMD mDFTR =
{
        2 + (DET_RAMP_LEVELS * 3) - 1,
        &mmXXTR[1],     /* XXTR[0] is only used by IFTR and IBTR */
        pFRONT_DET_TEMP,
        DetPreFunc,
        DummyFunction
};

const METHCMD mDBTR =
{
        2 + (DET_RAMP_LEVELS * 3) - 1,
        &mmXXTR[1],     /* XXTR[0] is only used by IFTR and IBTR */
        pBACK_DET_TEMP,
        DetPreFunc,
        DummyFunction
};

const METHCMD mOVTZ =
{
        MAXINDEX(mmXXTZ, METHCMD_ENTRY),
        &mmXXTZ[0],
        pOVEN_TEMP,
        DummyFunction,
        DummyFunction
};

const METHCMD mIFTZ =
{
        MAXINDEX(mmXXTZ, METHCMD_ENTRY),
        &mmXXTZ[0],
        pFRONT_INLET_TEMP,
        InletPreFunc,
        DummyFunction
};

const METHCMD mIBTZ =
{
        MAXINDEX(mmXXTZ, METHCMD_ENTRY),
        &mmXXTZ[0],
        pBACK_INLET_TEMP,
        InletPreFunc,
        DummyFunction
};

const METHCMD mA1TZ =
{
        MAXINDEX(mmXXTZ, METHCMD_ENTRY),
        &mmXXTZ[0],
        pAUX_1_TEMP,
        AuxPreFunc,
        DummyFunction
};

const METHCMD mA2TZ =
{
        MAXINDEX(mmXXTZ, METHCMD_ENTRY),
        &mmXXTZ[0],
        pAUX_2_TEMP,
        AuxPreFunc,
        DummyFunction
};

const METHCMD mDFTZ =
{
        MAXINDEX(mmXXTZ, METHCMD_ENTRY),
        &mmXXTZ[0],
        pFRONT_DET_TEMP,
        DetPreFunc,
        DummyFunction
};

const METHCMD mDBTZ =
{
        MAXINDEX(mmXXTZ, METHCMD_ENTRY),
        &mmXXTZ[0],
        pBACK_DET_TEMP,
        DetPreFunc,
        DummyFunction
};

/********************* "get" wrapper functions *********************/

static UI_ERR DummyFunction(void *which)
{
        (void) which;
        return OK;
}

static INT32 DummyGet(void *parm, U_INT8 num)
{
   (void)parm;
   (void)num;

   return 0;
}

static UI_ERR DummySet(void *parm, INT32 setpt, U_INT8 num)
{
   (void) parm;
   (void) setpt;
   (void) num;
   return OK;
}

static INT32 mGetOvenType(void *status, U_INT8 num)
{
        (void) num;
        (void) status;
        return (INT32)GetOvenType( );
}

static INT32 mGetOvenCalib(void *status, U_INT8 num)
{
        (void) num;
        (void) status;
        return (INT32)GetOvenCalib();
}

static INT32 mGetOvenCalibDate(void *status, U_INT8 num)
{
        (void) num;
        (void) status;
        return (INT32)SecondsSince1980( Zone_Config.oven_calib_date );
}

static INT32 mGetTempZonePresence(void *status, U_INT8 num)
{
        (void) num;
        return (INT32)GetTempZonePresence( pzone_status );
}

static INT32 mGetZonePresence(void *status, U_INT8 num)
{
        (void) num;
        return (INT32)GetZonePresence( pzone_status );
}

static INT32 mGetCryoType(void *zone, U_INT8 num)
{
        (void) num;
        return (INT32)GetCryoType( ((MULTI_PTRS * const)zone  )->pzone );
}

static INT32 mGetZoneCryoType(void *zone, U_INT8 num)
{
        (void) num;
        return (INT32)GetCryoType( zone );
}

static INT32 mGetAuxType(void *status, U_INT8 ramp_number)
{
        (void) ramp_number;
        return (INT32)GetAuxType(aux_index_status);
}

static INT32 mGetZoneMinSetpt(void *zone, U_INT8 ramp_number)
{
        (void) ramp_number;
        return GetZoneMinSetpt(((MULTI_PTRS * const)zone  )->pzone);
}

static INT32 mGetZoneMaxSetpt(void *zone, U_INT8 ramp_number)
{
        (void) ramp_number;

        if ((pZONE_TABLE)((MULTI_PTRS * const)zone)->pzone == pOVEN_TEMP )
        {
           return OVN_LIMIT;    /* Fixed upper oven limit, not oven max */
        }
        else
        {
           return GetZoneMaxSetpt(((MULTI_PTRS * const)zone  )->pzone);
        }
}

static INT32 mGetZoneMaxRate(void *zone, U_INT8 ramp_number)
{
        (void) ramp_number;
        return GetZoneMaxRate(((MULTI_PTRS * const)zone  )->pzone);
}

static INT32 mGetOvenMax(void *zone, U_INT8 ramp_number)
{
        (void) zone;
        (void) ramp_number;
        return GetOvenMax();
}

static INT32 mGetOvenEquibTime(void *zone, U_INT8 ramp_number)
{
        (void) zone;
        (void) ramp_number;
        return GetOvenEquibTime();
}

static INT32 mGetCryoOnOff(void *zone, U_INT8 ramp_number)
{
        (void) ramp_number;
        return (INT32)GetCryoOnOff( zone );
}

static INT32 mGetCryoBlastOnOff(void *zone, U_INT8 ramp_number)
{
        (void) ramp_number;
        return (INT32)GetCryoBlastOnOff( zone );
}

static INT32 mGetCryoAmbientTemp(void *zone, U_INT8 ramp_number)
{
        (void) ramp_number;
        return GetCryoAmbientTemp( zone );
}

static INT32 mGetCryoTimeout(void *zone, U_INT8 ramp_number)
{
        (void) ramp_number;
        return DCGetCryoTimeout( zone );
}

static INT32 mGetCryoTimeoutOnOff(void *zone, U_INT8 ramp_number)
{
        (void) ramp_number;
        return (INT32)GetCryoTimeoutOnOff( zone );
}

static INT32 mGetCryoShutdownOnOff(void *zone, U_INT8 ramp_number)
{
        (void) ramp_number;
        return (INT32)GetCryoShutdownOnOff( zone );
}

static INT32 mGetTempSetpt(void *zone, U_INT8 ramp_number)
{
        (void) ramp_number;
        return GetTempSetpt(zone);
}

static INT32 mGetOvenTrackModeOnOff(void *zone, U_INT8 ramp_number)
{
        (void) ramp_number;
        return (int) GetOvenTrackModeOnOff(zone);
}

static INT32 mGetInitTempSetpt(void *zone, U_INT8 ramp_number)
{
        (void) ramp_number;
        return GetInitTempSetpt(zone);
}

static INT32 mGetInitTimeSetpt(void *zone, U_INT8 ramp_number)
{
        (void) ramp_number;
        return GetInitTimeSetpt(zone);
}

static INT32 mGetRateSetpt(void *zone, U_INT8 ramp_number)
{
        return GetRateSetpt(zone, ramp_number);
}

static INT32 mGetFinalTempSetpt(void *zone, U_INT8 ramp_number)
{
        return GetFinalTempSetpt(zone, ramp_number);
}

static INT32 mGetFinalTimeSetpt(void *zone, U_INT8 ramp_number)
{
        return GetFinalTimeSetpt(zone, ramp_number);
}

static INT32 mGetTempOnOff(void *zone, U_INT8 ramp_number)
{
        (void) ramp_number;
        return (int) GetTempOnOffSetpt(zone);
}

/********************* "set" wrapper functions *********************/

static UI_ERR mSetOvenType(void *parm, INT32 setpt, U_INT8 num)
{
        (void) parm;
        (void) num;
        return SetOvenType( (OVEN_TYPE)setpt );
}

static UI_ERR mSetOvenMeasuredTemp(void *parm, INT32 setpt, U_INT8 num)
{
        (void) parm;
        (void) num;
        return SetOvenTempMeasured( setpt );
}

static UI_ERR mSetAuxType(void *status, INT32 setpt, U_INT8 ramp_number)
{
        (void) ramp_number;
        return SetAuxType( aux_index_status, (AUX_TYPE)setpt);
}

static UI_ERR mSetOvenMax(void *zone, INT32 setpt, U_INT8 ramp_number)
{
        (void) zone;
        (void) ramp_number;
        return TakeThisOvenMaxAndShoveIt(setpt);
}

static UI_ERR mSetOvenEquibTime(void *zone, INT32 setpt, U_INT8 ramp_number)
{
        (void) zone;
        (void) ramp_number;
        return SetOvenEquibTime(setpt);
}

static UI_ERR mSetCryoType(void *zone, INT32 setpt, U_INT8 ramp_number)
{
        (void) zone;
        (void) ramp_number;
        return SetCryoType( zone, (CRYO_TYPE) setpt);
}

static UI_ERR mSetCryoOnOff(void *zone, INT32 setpt, U_INT8 ramp_number)
{
        (void) zone;
        (void) ramp_number;
        return SetCryoOnOff( zone, (ON_OFF) setpt);
}

static UI_ERR mSetCryoBlastOnOff(void *zone, INT32 setpt, U_INT8 ramp_number)
{
        (void) zone;
        (void) ramp_number;
        return SetCryoBlastOnOff( zone, (ON_OFF) setpt);
}

static UI_ERR mSetCryoAmbientTemp(void *zone, INT32 setpt, U_INT8 ramp_number)
{
        (void) zone;
        (void) ramp_number;
        return SetCryoAmbientTemp( zone, setpt);
}

static UI_ERR mSetCryoTimeout(void *zone, INT32 setpt, U_INT8 ramp_number)
{
        (void) zone;
        (void) ramp_number;
        return DCSetCryoTimeout( zone, setpt);
}

static UI_ERR mSetCryoTimeoutOnOff(void *zone, INT32 setpt, U_INT8 ramp_number)
{
        (void) zone;
        (void) ramp_number;
        return SetCryoTimeoutOnOff( zone, (ON_OFF) setpt);
}

static UI_ERR mSetCryoShutdownOnOff(void *zone, INT32 setpt, U_INT8 ramp_number)
{
        (void) zone;
        (void) ramp_number;
        return SetCryoShutdownOnOff( zone, (ON_OFF) setpt);
}

static UI_ERR mSetTempSetpt(void *zone, INT32 setpt, U_INT8 ramp_number)
{
        (void) ramp_number;
        return SetTempSetpt(zone, setpt);
}

static UI_ERR mSetOvenTrackModeOnOff(void *zone, INT32 setpt, U_INT8 ramp_number)
{
        (void) ramp_number;
        return SetOvenTrackModeOnOff(zone, (ON_OFF) setpt);
}

static UI_ERR mSetInitTempSetpt(void *zone, INT32 setpt, U_INT8 ramp_number)
{
        (void) ramp_number;
        return SetInitTempSetpt(zone, setpt);
}

static UI_ERR mSetInitTimeSetpt(void *zone, INT32 setpt, U_INT8 ramp_number)
{
        (void) ramp_number;
        return SetInitTimeSetpt(zone, setpt);
}

static UI_ERR mSetRateSetpt(void *zone, INT32 setpt, U_INT8 ramp_number)
{
        return SetRateSetpt(zone, setpt, ramp_number);
}

static UI_ERR mSetFinalTempSetpt(void *zone, INT32 setpt, U_INT8 ramp_number)
{
        return SetFinalTempSetpt(zone, setpt, ramp_number);
}

static UI_ERR mSetFinalTimeSetpt(void *zone, INT32 setpt, U_INT8 ramp_number)
{
        return SetFinalTimeSetpt(zone, setpt, ramp_number);
}

static UI_ERR mSetTempOnOff(void *zone, INT32 setpt, U_INT8 ramp_number)
{
        (void) ramp_number;
        return ((ON_OFF) setpt == ON) ? SetTempOn(zone) : SetTempOff(zone);
}

/********************* "let" wrapper functions *********************/

static UI_ERR mLetAuxType (void *status, INT32 setpt, U_INT8 num)
{
        (void)num;

        gccw.AuxType[aux_index_status - 1] = (AUX_TYPE)setpt;
        return OK;
}

static UI_ERR mLetOvenType (void *status, INT32 setpt, U_INT8 num)
{
        (void)status;
        (void)num;

        gccw.OvenType = (BIT8)setpt;
        return OK;
}

static UI_ERR mLetZonePresence (void *status, INT32 setpt, U_INT8 num)
{
        (void)num;

        gccw.ZonePresence[(int)zone_type_status] = (BIT8)(ZONE_PRESENCE)setpt;
        return OK;
}

static UI_ERR mLetCryoType (void *status, INT32 setpt, U_INT8 num)
{
        (void)status;
        (void)num;

        gccw.CryoType = (CRYO_TYPE)setpt;
        return OK;
}

static UI_ERR mLetOvenMax (void *status, INT32 setpt, U_INT8 num)
{
        (void)status;
        (void)num;

        gccw.OvenMax = setpt;
        return OK;
}

static UI_ERR mLetZoneMinSetpt (void *status, INT32 setpt, U_INT8 num)
{
        (void)num;
        gccw.ZoneMinSetpt[(int)zone_type_status] = (INT16)setpt;
        return OK;
}

static UI_ERR mLetZoneMaxSetpt (void *status, INT32 setpt, U_INT8 num)
{
        (void)num;
        gccw.ZoneMaxSetpt[(int)zone_type_status] = (U_INT16)setpt;
        return OK;
}

static UI_ERR mLetZoneMaxRate (void *status, INT32 setpt, U_INT8 num)
{
        (void)num;
        gccw.ZoneMaxRate[(int)zone_type_status] = (U_INT32)setpt;
        return OK;
}

/* Pre/Post Functions */


static UI_ERR AuxPreFunc(void *which)
{
   EXCEPTION exception;

   if ( DoingMethodInstall() )
   {
      if ( which == (const pZONE_TABLE)pAUX_1_TEMP )
      {
         exception = AUX_1_MISMATCH;
      }
      else
      {
         exception = AUX_2_MISMATCH;
      }

      if ( TestForException ( exception ) )
      {
         return NOT_ALLOWED;
      }
   }

   /* The aux temperature setpts will be part of the method for */
   /* the FPD for backward compatibility, but we will ignore    */
   /* them.                                                     */
   if ( GetAuxType( (which==&Auxa_Table)?1:2 ) == FPD_AUX )
   {
      return IGNORE_SETPTS;
   }

   return OK;
}

static UI_ERR CryoPreFunc(void *which)
{
   EXCEPTION exception;
   pZONE_TABLE pzone;

   pzone = which;

   if ( DoingMethodInstall() )
   {
      switch ( pzone->config->zone_location )
      {
         case OVEN_ZONE:
            exception = CRYO_MISMATCH;
            break;

         case INJA_ZONE:
            exception = F_INLET_CRYO_MISMATCH;
            break;

         case INJB_ZONE:
            exception = B_INLET_CRYO_MISMATCH;
            break;

         case AUXA_ZONE:
            exception = AUX1_CRYO_MISMATCH;
            break;

         case AUXB_ZONE:
            exception = AUX2_CRYO_MISMATCH;
            break;

         default: return NOT_ALLOWED;
      }

      if ( TestForException( exception ) )
      {
         return NOT_ALLOWED;
      }

   }

   return OK;
}

static UI_ERR InletPreFunc(void *which)
{
   EXCEPTION exception;

   if ( DoingMethodInstall() )
   {
      if ( which == (const pZONE_TABLE)pFRONT_INLET_TEMP )
      {
         exception = FRNT_INLET_TYPE;
      }
      else
      {
         exception = BACK_INLET_TYPE;
      }

      if ( TestForException ( exception ) )
      {
         return NOT_ALLOWED;
      }
   }

   return OK;
}

static UI_ERR DetPreFunc(void *which)
{
   EXCEPTION exception;

   if ( DoingMethodInstall() )
   {
      if ( which == (const pZONE_TABLE)pFRONT_DET_TEMP )
      {
         exception = FRNT_DET_TYPE_MISMATCH;
      }
      else
      {
         exception = BACK_DET_TYPE_MISMATCH;
      }

      if ( TestForException ( exception ) )
      {
         return NOT_ALLOWED;
      }
   }

   return OK;
}

